/**************************************************************************(C)*
 *
 *  This file is part of the GreenHills project
 *  Copyright (C) 2009  Tieto Corporation
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  Not for commmercial use. Only with Tieto permission.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *************************************************************************(C)*/
#pragma once
#include "maplabel.h"
#include "userlabels.h"
#include "gps/gpsmapviewmathematic.h"
#include "mapscene.h"
#include <QMouseEvent>
#include <QNetworkAccessManager>
#include <QTWebKit/QWebView>
#include <QtGui/QWidget>
#include <QGraphicsScene>

namespace Ui {
    class CMapWiev;
}

namespace greenhills{

    namespace client{

class CMapWiev : public QWidget {
    Q_OBJECT
public:
    CMapWiev(QString pKey, QWidget *parent = 0);
    ~CMapWiev();


protected:
    void changeEvent(QEvent * e);
    void resizeEvent(QResizeEvent * event);


private:    
    CMapLabel * selectedTarget() const;
    void resizeRedraw();
    void createUserLable();
    void wayPointCreate();
    void moveTargets();    


    QPointF mCoordinates;
    QPointF mPosun;
    QNetworkAccessManager * mManager;
    QString mKey;
    QGraphicsPixmapItem * mImgPointer;
    QImage mImg;
    CMapScene  * mScene;
    CUserlabels * mLabel;   
    Ui::CMapWiev *m_ui;
    greenhills::gps::CGpsmapViewMathematic * mMath;
    float mOldHeading;    
    QGraphicsItemGroup *mGroup;
    bool mZmena;

public slots:
     void replyFinished(QNetworkReply *mReply);
     void onUserHeadingChange(float heading);
     void onUserHeadingChange(QString heading);
     void onWayPointCreate();
     void onWayPointDelete();
     void onChangePosition();
     void onMapRedrawNeed(QPointF * pPosun);
     void mouseChangeLabel(double x,double y);
     void firstPaint();
};
}
}
